﻿using iMES.Core.Enums;
using iMES.Core.Filters;
using iMES.Entity.DomainModels;
using iMES.Mass.IServices;
using iMES.Mass.Services;
using iMES.Quality.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;

namespace iMES.Mass.Controllers
{
    public partial class Mass_DetectionTemplateController
    {
        private readonly IMass_DetectionTemplateService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;
        [ActivatorUtilitiesConstructor]
        public Mass_DetectionTemplateController(
            IMass_DetectionTemplateService service,
            IHttpContextAccessor httpContextAccessor
        ) : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        /// <summary>
        /// 获取table1的数据
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [Route("getTable1Data_Mass_DetectionTemplate"), HttpPost, ApiActionPermission("Mass_DetectionTemplate", ActionPermissionOptions.Search)]
        public async Task<IActionResult> GetTable1Data([FromBody] PageDataOptions loadData)
        {
            return JsonNormal(await Service.GetTable1Data(loadData));
        }

        /// <summary>
        /// 获取table1的数据
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [Route("getTable2Data_Mass_DetectionTemplate"), HttpPost, ApiActionPermission("Mass_DetectionTemplate", ActionPermissionOptions.Search)]
        public async Task<IActionResult> GetTable2Data([FromBody] PageDataOptions loadData)
        {
            return JsonNormal(await Service.GetTable2Data(loadData));
        }
        [HttpPost, Route("getSelectorTemplate")]
        public IActionResult getSelectorTemplate([FromBody] PageDataOptions options)
        {
            //1.可以直接调用框架的GetPageData查询
            PageGridData<Mass_DetectionTemplate> data = Mass_DetectionTemplateService.Instance.GetPageData(options);
            return JsonNormal(data);
        }
    }
}
